//
//  RTNavgationController.swift
//  Weibo
//
//  Created by Brisinga on 16/3/2.
//  Copyright © 2016年 Root. All rights reserved.
//

import UIKit

class RTNavgationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    // 重写push方法
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count>0 {
            
            var title: String?
            
            if childViewControllers.count==1 {
                
                title = "返回"
            }
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageNamed: "navigationbar_back_withtext", title: title, target: self, action: "popViewController")
            
            self.hidesBottomBarWhenPushed = true
        }
        
        super.pushViewController(viewController, animated: true)
        
    }
    
    
    
   @objc private func popViewController() {
        
        popViewControllerAnimated(true)
    }

}
